@use 'sass:map';

@use '../mixins/mixins' as *;
@use '../mixins/var' as *;
@use '../common/var' as *;
@use '../common/transition' as *;

@include b(picker) {
  @include e(popper) {
    @include set-css-var-type('datepicker', 'border-color', $datepicker);
    @include picker-popper(
      getCssVar('bg-color', 'overlay'),
      1px solid getCssVar('datepicker', 'border-color'),
      getCssVar('box-shadow', 'light')
    );
  }
}

@include b(date-editor) {
  @include set-component-css-var('date-editor', $date-editor);
  @include set-component-css-var('input', $input);
  position: relative;
  display: inline-block;
  text-align: left;

  &.#{$namespace}-input__inner {
    border-radius: var(--el-input-border-radius, var(--el-border-radius-base));

    @include inset-input-border(
      var(--el-input-border-color, map.get($input, 'border-color'))
    );

    &:hover {
      @include inset-input-border(var(--el-input-hover-border-color));
    }
  }

  &.#{$namespace}-input,
  &.#{$namespace}-input__inner {
    width: var(--el-date-editor-width);
  }

  @include m((monthrange)) {
    &.#{$namespace}-input,
    &.#{$namespace}-input__inner {
      width: var(--el-date-editor-monthrange-width);
    }
  }

  @include m((daterange, timerange)) {
    &.#{$namespace}-input,
    &.#{$namespace}-input__inner {
      width: var(--el-date-editor-daterange-width);
    }
  }

  @include m(datetimerange) {
    &.#{$namespace}-input,
    &.#{$namespace}-input__inner {
      width: var(--el-date-editor-datetimerange-width);
    }
  }

  @include m(dates) {
    .#{$namespace}-input__inner {
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  .close-icon {
    cursor: pointer;
  }

  .clear-icon {
    cursor: pointer;

    &:hover {
      color: var(--el-text-color-secondary);
    }
  }

  .#{$namespace}-range__icon {
    height: inherit;
    font-size: 14px;
    color: var(--el-text-color-placeholder);
    float: left;

    svg {
      vertical-align: middle;
    }
  }

  .#{$namespace}-range-input {
    appearance: none;
    border: none;
    outline: none;
    display: inline-block;
    height: 100%;
    margin: 0;
    padding: 0;
    width: 39%;
    text-align: center;
    font-size: var(--el-font-size-base);
    color: var(--el-text-color-regular);
    background-color: transparent;

    &::placeholder {
      color: var(--el-text-color-placeholder);
    }
  }

  .#{$namespace}-range-separator {
    flex: 1;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    padding: 0 5px;
    margin: 0;
    font-size: 14px;
    word-break: keep-all;
    color: var(--el-text-color-primary);
  }

  .#{$namespace}-range__close-icon {
    font-size: 14px;
    color: var(--el-text-color-placeholder);
    height: inherit;
    width: unset;
    cursor: pointer;

    &:hover {
      color: var(--el-text-color-secondary);
    }

    svg {
      vertical-align: middle;
    }

    &--hidden {
      opacity: 0;
      visibility: hidden;
    }
  }
}

@include b(range-editor) {
  &.#{$namespace}-input__inner {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
  }

  .#{$namespace}-range-input {
    line-height: 1;
  }

  @include when(active) {
    @include inset-input-border(var(--el-input-focus-border-color));
    &:hover {
      @include inset-input-border(var(--el-input-focus-border-color));
    }
  }

  @each $size in (large, small) {
    @include m($size) {
      line-height: map.get($input-height, $size);

      &.#{$namespace}-input__inner {
        height: map.get($input-height, $size);
      }

      .#{$namespace}-range-separator {
        line-height: map.get($input-line-height, $size);
        font-size: map.get($input-font-size, $size);
      }

      .#{$namespace}-range-input {
        font-size: map.get($input-font-size, $size);
      }
    }
  }

  @include when(disabled) {
    background-color: map.get($input-disabled, 'fill');
    border-color: map.get($input-disabled, 'border');
    color: map.get($input-disabled, 'text-color');
    cursor: not-allowed;

    &:hover,
    &:focus {
      border-color: map.get($input-disabled, 'border');
    }

    input {
      background-color: map.get($input-disabled, 'fill');
      color: map.get($input-disabled, 'text-color');
      cursor: not-allowed;
      &::placeholder {
        color: map.get($input-disabled, 'placeholder-color');
      }
    }

    .#{$namespace}-range-separator {
      color: map.get($input-disabled, 'text-color');
    }
  }
}
